import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)
let originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(path){
  return originalPush.call(this,path).catch(err=>err)
}
const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/dashboard',
    name: 'Dabashboard',
    component: ()=>import("../components/dashboard/Dashboard"),
    children:[
      {
        path:"",
        name:"home",
        component:()=>import("../components/dashboard/Home"),
        meta:[]
      },{
        path:"/userlist",
        name:"userlist",
        component:()=>import("../components/dashboard/UserList"),
        meta:["数据管理","用户列表"]
      },
      {
        path:"/adminlist",
        name:"adminlist",
        component:()=>import("../components/dashboard/AdminList"),
        meta:["数据管理","管理员列表"]
      },
      {
        path:"/orderlist",
        name:"orderlist",
        component:()=>import("../components/dashboard/OrderList"),
        meta:["数据管理","订单列表"]
      },
      {
        path:"/shoplist",
        name:"shoplist",
        component:()=>import("../components/dashboard/ShopList"),
        meta:["数据管理","商家列表"]
      },
      {
        path:"/foodlist",
        name:"foodlist",
        component:()=>import("../components/dashboard/FoodList"),
        meta:["数据管理","商品列表"]
      },
      {
        path:"/addFoods",
        name:"addFoods",
        component:()=>import("../components/dashboard/AddFoods"),
        meta:["数据管理","添加食品"]
      },
      {
        path:"/addShops",
        name:"addShops",
        component:()=>import("../components/dashboard/AddShops"),
        meta:["数据管理","添加商品"]
      }
    ]
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
